package org.softmed.rest.server.control;

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import org.softmed.rest.editor.commons.AddressBar;
import org.softmed.rest.editor.commons.SwingUtil;

public class ControlPanel extends JFrame {

	AddressBar addressBar = new AddressBar();
	ControlPane controlPane = new ControlPane();

	public ControlPanel() {

		controlPane.setUriProvider(addressBar);

		SwingUtil.setSize(this, 580, 190);
		setResizable(false);
		setTitle("REST Server Control Panel");
		setLayout(new BorderLayout());

		add(addressBar, BorderLayout.NORTH);
		add(controlPane, BorderLayout.CENTER);

		pack();
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent we) {
				try {
					addressBar.writeLastURI();
				} catch (Throwable e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				System.exit(0);

			}
		});

		setVisible(true);

	}

}
